home *** CD-ROM | disk | FTP | other *** search
- Path: csus.edu!news
- From: gustavo.sandoval@csus.edu (gustavo sandoval)
- Newsgroups: comp.lang.c++
- Subject: weird behavior
- Date: 27 Jan 1996 11:07:01 GMT
- Organization: Your Organization
- Message-ID: <4ed10l$jap@news.csus.edu>
- NNTP-Posting-Host: @u0106-p18.dialin.csus.edu
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- I have the following linked list which I'm playing around with:
-
- class CList
- {
- public:
- CList();
- ~CList();
-
- void Insert(int element);
- void Print ();
-
- // Returns the number or items deleted
- int Delete(int target);
-
- private:
- CItem* head;
-
- };// CList
-
- // Implementation of the functions omitted
-
- // In main I have:
-
- void main ()
- {
- CList MyList;
-
- for (int x = 0; x < 10; x++ )
- MyList.Insert (x*10);
-
- MyList.Print();
-
- int count = MyList.Delete (40);
-
- MyList.Insert (50);
- MyList.Insert; // <== this lines
- MyList.Print; // <== this lines
-
- count = MyList.Delete (50);
-
- }
-
-
- note the lines with the arrows. The code compiles in VC 4.0 without warnings
- in level 4 or errors. When I step through those two lines the debugger just
- goes right by.
-
- Also I looked at the disassembly and I have the following:
-
- 181: MyList.Insert (50);
- 00401541 push 00000032
- 00401543 lea ecx,dword ptr [MyList]
- 00401546 call @ILT+10(?Insert@CList@@QAEXH@Z) (0040100a)
- 182: MyList.Insert;
- 183: MyList.Print;
- 184:
- 185: count = MyList.Delete (50);
- 0040154b push 00000032
- 0040154d lea ecx,dword ptr [MyList]
- 00401550 call @ILT+65(?Delete@CList@@QAEHH@Z) (00401041)
- 00401555 mov dword ptr [count],eax
-
-
- It just seems that the compiler is inserting no-ops. Is this the right
- behavior. To me this seems like a bug that the compiler is not catching, but
- then what do I know.
-
- thanks in advance,
-
- gustavo
-
-